<?php
/**
 * (ajax)
 */
namespace App\Admin\Ajax\ZiNiao;

use App\Models\ZiNiao\PlansTasks;
use Illuminate\Support\Facades\Artisan;
class PlansTasksAjax {

    public function tasks($id){
        try{
            $model = PlansTasks::query()->findOrFail($id);
            if(!$model || $model->status == 1){
                return response()->json(['status' => false, 'message' => '状态有误！']);
            }
            Artisan::call('ziniao:tasks', ['planId' => $model->planId]);
            return response()->json(['status' => true, 'message' => '操作成功！']);
        }catch (\Exception $e){
            report($e);
            return response()->json(['status' => false, 'message' => '系统异常！']);
        }
    }
}
